import { getToken } from '@/utils/auth'
import config from '@/config'
import { toast, showConfirm, tansParams } from '@/utils/common'


let timeout = 10000
const baseUrl = config.baseUrl
export function uniRequest(config,succ,err){
	let header = {
		'Authorization':'Bearer ' + getToken(),
		'Content-Type':'application/json;charset=utf-8',
		'Content-Language':'zh_CN'
	}
	if (config.params) {
	  let url = config.url + '?' + tansParams(config.params)
	  url = url.slice(0, -1)
	  config.url = url
	}
	uni.request({
		method: config.method || 'get',
		timeout: timeout,
		url: baseUrl +"/" + config.url,
		data: config.data,
		header: header,
		dataType: 'json',
		success(res) {
			succ(res);
		},
		fail(e) {
			err(e);
		}
	})
}


export default uniRequest;